package tests

import helper.base.string.ReplaceHelper.replaceLastOccurrence
import org.junit.Test

internal class T_2023_1016 {
    @Test
    fun t_2023_1016_000649_(){
        // 测试案例1：替换最后一个 "apple" 为 "banana"
        val original1 = "apple orange apple"
        val newString1 = original1.replaceLastOccurrence("apple", "banana")
        assert(newString1 == "apple orange banana")

        // 测试案例2：字符串中没有 "mango"，所以原样输出
        val original2 = "apple orange apple"
        val newString2 = original2.replaceLastOccurrence("mango", "banana")
        assert(newString2 == "apple orange apple")

        // 测试案例3：替换最后一个空格为一个逗号
        val original3 = "apple orange apple"
        val newString3 = original3.replaceLastOccurrence(" ", ", ")
        assert(newString3 == "apple orange, apple")

        // 测试案例4：替换最后一个 "a" 为 "A"
        val original4 = "a a a a"
        val newString4 = original4.replaceLastOccurrence("a", "A")
        assert(newString4 == "a a a A")

        println("All test cases passed!")
    }
}